<?php
/**
 * 回答记录联表查询
 */
namespace Home\Model;
use Think\Model\RelationModel;
class AnswerModel extends RelationModel{
    protected $_link=array(
        'aext'=>array(
            'mapping_type'=>self::HAS_ONE,
            'foreign_key'=>'aid',//本表外键
            'class_name'=>'answer_ext',//从表的完整名字
            'mapping_name'=>'aext',
            // 'as_fields' => 'kiss,avatar,sign,vip,qq,wechat'
            ),
        'user'=>array(
            'mapping_type'=>self::BELONGS_TO,
            'foreign_key'=>'uid',
            'class_name'=>'users',//从表的完整名字
            'mapping_name'=>'user',
            'mapping_fields' => 'uname'
            ),
        'usext'=>array(
            'mapping_type'=>self::BELONGS_TO,
            'foreign_key'=>'uid',
            'class_name'=>'users_ext',//从表的完整名字
            'mapping_name'=>'uext',
            'mapping_fields' => 'avatar'
            ),
        'q'=>array(
            'mapping_type'=>self::BELONGS_TO,
            'foreign_key'=>'qid',
            'class_name'=>'question',//从表的完整名字
            'mapping_name'=>'q',
            'mapping_fields' => 'uid'
            ),
        'qext'=>array(
            'mapping_type'=>self::BELONGS_TO,
            'foreign_key'=>'qid',
            'class_name'=>'question_ext',//从表的完整名字
            'mapping_name'=>'qext',
            'mapping_fields' => 'close'
            )
    );
}